From: Waldir Pimenta Date: Wed, 7 Nov 2012 12:54:24 +0000 (+0000) Subject: Improve documentation for "pipe trick" X-Git-Tag: 1.31.0-rc.0~20933^2~1 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=600ecaf7be67647b78138e94bb0a17b044aa7197;p=lhc%2Fweb%2Fwiklou.git Improve documentation for "pipe trick" - Actually mention "pipe trick" so the code is searchable - Use spaces rather than tabs for vertical alignment - Clarify comment for double-width brackets and mention revision it was added Change-Id: Iaf365e313144e378133fb16c64efa5b7e47d4a6a --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index b31288f58d..5699ef8d43 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4478,14 +4478,14 @@ class Parser { '~~~' => $sigText ) ); - # Context links: [[|name]] and [[name (context)|]] + # Context links ("pipe trick"): [[|name]] and [[name (context)|]] $tc = '[' . Title::legalChars() . ']'; $nc = '[ _0-9A-Za-z\x80-\xff-]'; # Namespaces can use non-ascii! - $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/"; # [[ns:page (context)|]] - $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/"; # [[ns:page(context)|]] - $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/"; # [[ns:page (context), context|]] - $p2 = "/\[\[\\|($tc+)]]/"; # [[|page]] + $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/"; # [[ns:page (context)|]] + $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/"; # [[ns:page(context)|]] (double-width brackets, added in r40257) + $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/"; # [[ns:page (context), context|]] + $p2 = "/\[\[\\|($tc+)]]/"; # [[|page]] # try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]" $text = preg_replace( $p1, '[[\\1\\2\\3|\\2]]', $text );